#include<bits/stdc++.h>
#define N 10055
#define int __int128
#define double long double
using namespace std;
int T;
int ans_car = 0;
int ans_check = 0;
int n, m, L, V;
int mx = LLONG_MIN;
bool used_check[N];
bool faster_cars[N];
int d[N], v[N], a[N], p[N];
const double eps = 1e-7;
inline void read(int &x);
inline void write(int x, bool enter);
void init()
{

    n = m = L = V = 0;
    ans_check = LLONG_MAX;
    memset(d, 0, sizeof d);
    memset(v, 0, sizeof v);
    memset(a, 0, sizeof a);
    memset(p, 0, sizeof p);
    memset(used_check, 0, sizeof used_check);
    memset(faster_cars, 0, sizeof faster_cars);
}
inline double calc(int v0, int v1, int a)
{
    return (double)(((double)(v1 * v1 - v0 * v0)) / (double)(2.0 * a));
}
inline bool check_integer(double x)
{
    if((int)x == x)
    {
        return 1;
    }
    return 0;
}
void shen_sou_lao_dian_fen(int x)
{
    if(x == 1 << (m + 1))
    {
        return ;
    }
    int ans = 0;
    for(int i = 1;i <= n;++i)
    {
        int len = calc(v[i], V, a[i]);
        for(int j = 1;j <= m;++j)
        {
            if(!((x >> (j - 1)) & 1))
            {
                continue;
            }
            if(len + eps < 0)
            {
                if(d[i] <= p[j])
                {
                    ++ans;
                }
            }
            else if(a[i] > 0)
            {
                if(p[j] >= (double)(len + d[i]))
                {
                    ++ans;
                }
            }
            else if(a[i] < 0)
            {
                if(p[j] < (len + d[i] + eps) && p[j] >= d[i])
                {
                    ++ans;
                }
            }
        }
    }
    if(ans == ans_car)
    {
        int tmp = 0;
        while(x)
        {
            tmp += !(x & 1);
            x >>= 1;
        }
        mx = max(tmp, mx);
    }
    shen_sou_lao_dian_fen(x + 1);
}
void work()
{
    ans_car = 0;
    ans_check = 0;
    read(n);
    read(m);
    read(L);
    read(V);
    bool check_A = 1;
    for(int i = 1;i <= n;++i)
    {
        read(d[i]);
        read(v[i]);
        read(a[i]);
        if(a[i] != 0)
        {
            check_A = 0;
        }
    }
    for(int i = 1;i <= m;++i)
    {
        read(p[i]);
    }
    if(n <= 25 && m <= 25)
    {
        for(int i = 1;i <= n;++i)
        {
            int len = calc(v[i], V, a[i]);
            for(int j = 1;j <= m;++j)
            {
                if(len + eps < 0)
                {
                    if(d[i] <= p[j])
                    {
                        ++ans_car;
                    }
                }
                else if(a[i] > 0)
                {
                    if(p[j] >= (double)(len + d[i]))
                    {
                        ++ans_car;
                    }
                }
                else if(a[i] < 0)
                {
                    if(p[j] < (len + d[i] + eps) && p[j] >= d[i])
                    {
                        ++ans_car;
                    }
                }
            }
        }
        write(ans_car, 0);
        putchar(' ');
        write(mx, 1);
    }
    if(check_A)
    {   ans_car = 0;
        ans_check = 0;
        for(int i = 1;i <= n;++i)
        {
            if(v[i] > V)
            {
                for(int j = 1;j <= m;++j)
                {
                    if(d[i] <= p[j] && p[j] <= L)
                    {
                        faster_cars[i] = 1;
                        used_check[j] = 1;
                    }
                }
            }
        }
        for(int i = 1;i <= n;++i)
        {
            if(faster_cars[i])
            {
                ++ans_car;
            }
        }
        for(int i = 1;i <= n;++i)
        {
            if(used_check[i])
            {
                ++ans_check;
            }
        }
        write(ans_car, 0);
        putchar(' ');
        write(ans_check, 1);
    }
}
signed main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    read(T);
    while(T--)
    {
        init();
        work();
    }
    return 0;
}
inline void read(int &x)
{
    x = 0;
    short flag = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')
        {
            flag = -1;
        }
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + ch - 48;
        ch = getchar();
    }
    x *= flag;
}
inline void write(int x, bool enter)
{
    if(x < 0)
    {
        putchar('-');
        x = -x;
    }
    static int sta[42] = {0};
    int top = 0;
    do
    {
        sta[++top] = x % 10;
        x /= 10;
    }
    while(x);
    while(top)
    {
        putchar(sta[top--] + 48);
    }
    if(enter)
    {
        putchar('\n');
    }
}
